package gui.menu;

import gui.MenuButton;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;

import control.MainMenuManager;


public class MainMenu extends JPanel implements Menu {
	MenuButton newGame;
	MenuButton options;
	MenuButton highscores;
	MenuButton about;
	MenuButton help;
	MenuButton exit;

	JPanel menu;

	
	public MainMenu(MainMenuManager manager, Color bgcolor) {
		super();
		init(manager, bgcolor);
	}
	
	
//	public void show() {
//		setVisible(true);
//	}
//	
//	@Override
//	public void close() {
//		setVisible(false);
//	}
	
	public void init(MainMenuManager manager, Color bgcolor){
		
		this.removeAll();
		
		menu = new JPanel();
		setBackground(bgcolor);
		menu.setBackground(bgcolor);
		newGame = new MenuButton("New Game", manager);
		options = new MenuButton("Options", manager);
		highscores = new MenuButton("Highscores", manager);
		help = new MenuButton("Help", manager);
		exit = new MenuButton("Exit", manager);

		BorderLayout border = new BorderLayout();
		setLayout(border);
		
		BoxLayout box = new BoxLayout(menu,BoxLayout.Y_AXIS);
		menu.setLayout(box);
		
		menu.add(newGame);
		menu.add(options);
		menu.add(highscores);
		menu.add(help);
		menu.add(exit);
		
		Box menuBox = Box.createVerticalBox();
		
		menuBox.add(Box.createVerticalBox());
		menuBox.add(Box.createVerticalGlue());
		menuBox.add(menu);
		menuBox.add(Box.createVerticalGlue());
		menuBox.add(Box.createVerticalBox());
		
		menuBox.setBackground(bgcolor);
		add(menuBox,BorderLayout.CENTER);
		

	}
	
	public static void main(String[] args) {
		JFrame test = new JFrame();
		test.add( new MainMenu(null, Color.BLACK) );
		test.setVisible(true);
		test.setSize(500, 550);
		test.setLocationRelativeTo(null);
		test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}
